Here is yet another example of co-operation amongst members of our E-group. In fact almost the only input I am making is to edit the article and show a very simple example in action. The original 16-bit program was supplied with LB version 2.02, and this is an example of how Stefan Pendl at megabit@t-online has upgraded it to 32-bit.
For experimenters who might like to change the cursor to any of the 25 inside the useful USER32.DLL , the following programs may be of interest. The first program is Stefan's updated version allowing you to see examples of the cursors available, and the second program is my simple attempt to show a change of cursor in action, without the need to select from an array.
Gordon Sweet -- Gordon@gsweet.fsnet.co.uk
'Cursor Example by Mitchell Kotler
'How to use LoadCursor and SetCursor to access more Window's Cursors
'No more flickering!
'modified Nov 26, 2000 awatson
'modified Jan 07, 2004 s.pendl
'modified Apr 01, 2004 s.pendl
DIM Cursors$(27)
Cursors$(1) = "512 arrow"
Cursors$(2) = "513 I beam"
Cursors$(3) = "514 hourglass"
Cursors$(4) = "515 crosshair"
Cursors$(5) = "516 up arrow"
Cursors$(8) = "642 nwse"
Cursors$(9) = "643 nesw"
Cursors$(10) = "644 ew"
Cursors$(11) = "645 ns"
Cursors$(12) = "646 nesw"
Cursors$(13) = "648 no sign"
Cursors$(14) = "649 pointing hand"
Cursors$(15) = "650 arrow and hourglass"
Cursors$(16) = "651 arrow and question"
Cursors$(17) = "652 big ns"
Cursors$(18) = "653 big ew"
Cursors$(19) = "654 big nesw"
Cursors$(20) = "655 big n"
Cursors$(21) = "656 big s"
Cursors$(22) = "657 big w"
Cursors$(23) = "658 big e"
Cursors$(24) = "659 big nw"
Cursors$(25) = "660 big ne"
Cursors$(26) = "661 big sw"
Cursors$(27) = "662 big se"
'BEGIN
nomainwin
statictext #1.s, "", 20, 20, 200, 20
combobox #1.c, Cursors$(),[changeCursor],20,60,150,300
open "Cursor Example" for window as #1
print #1, "trapclose [quit]"
print #1.c, "selectindex 1"
print #1.c, "setfocus"
print #1.s, Cursors$(1)
h=hwnd(#1)
call setClass h
goto [changeCursor]
[loop]
call SetCursor CursorHandle
scan
goto [loop]
[quit]
close #1
end
'This routine changes which cursor is loaded
[changeCursor]
print #1.c, "selection? item$"
if item$ = "" then item$ = Cursors$(1)
cursorNum=val(str$(32)+word$(item$,1))
CursorHandle=LoadCursor(cursorNum)
print #1.s, "32"+item$
goto [loop]
sub SetCursor hCursor
calldll #user32, "SetCursor",_
hCursor as long,_
result as long
end sub
'This loads the cursor and returns the cursor's handle
function LoadCursor(CursorName)
flags = hexdec("8000") or _LR_DEFAULTSIZE
calldll #user32, "LoadImageA",_
0 As long,_
CursorName As long,_
_IMAGE_CURSOR as long,_
0 as long,_
0 as long,_
flags as long,_
hCursor As long
call SetCursor hCursor
LoadCursor=hCursor
end function
sub setClass hWnd
index=_GCL_HCURSOR or 0 'which part to set
value=0 'set it to null
calldll #user32, "SetClassLongA",_
hWnd as long,_
index as long,_
value as long,_
result as long
end sub
‘‘**************** SECOND PROGRAM *****************
' TO CHANGE THE CURSOR COPY ANY TO BELOW AS INDICATED
' "512 arrow" "513 I beam" "514 hourglass" "515 crosshair" "516 up arrow"
' "642 nwse" "643 nesw" "644 ew" "645 ns" "646 nesw" "648 no sign"
' "649 pointing hand" "650 arrow and hourglass" "651 arrow and question"
' "652 big ns" "653 big ew" "654 big nesw" "655 big n" "656 big s"
' "657 big w" "658 big e" "659 big nw" "660 big ne" "661 big sw" "662 big se"
nomainwin
open "Cursor Example - LEFT CLICK TO SHOW x y" for graphics_fs as #1
print #1, "trapclose [quit]; down; when leftButtonUp [point]"
h=hwnd(#1)
call setClass h
'This routine changes which cursor is loaded
item$ = "649 pointing hand" ' CHANGE TO CHOICE
cursorNum=val(str$(32)+word$(item$,1))
CursorHandle=LoadCursor(cursorNum)
[loop]
call SetCursor CursorHandle
scan
goto [loop]
[point]
' insert any routine that uses [loop]
#1 "place 100 100"
#1 "\ "
#1 "\";MouseX;" ";MouseY
goto [loop]
[quit]
close #1
end
sub SetCursor hCursor
calldll #user32, "SetCursor",_
hCursor as long,_
result as long
end sub
'This loads the cursor and returns the cursor's handle
function LoadCursor(CursorName)
flags = hexdec("8000") or _LR_DEFAULTSIZE
calldll #user32, "LoadImageA",_
0 As long,_
CursorName As long,_
_IMAGE_CURSOR as long,_
0 as long,_
0 as long,_
flags as long,_
hCursor As long
call SetCursor hCursor
LoadCursor=hCursor
end function
sub setClass hWnd
index=_GCL_HCURSOR or 0 'which part to set
value=0 'set it to null
calldll #user32, "SetClassLongA",_
hWnd as long,_
index as long,_
value as long,_
result as long
end sub